package org.wattdepot.cli.commands;

import org.wattdepot.client.WattDepotClient;
import org.wattdepot.client.WattDepotClientException;

/**
 * Checks if the source exist.
 * 
 * @author David Joel Lazaro
 * 
 */
public class SourceChecker {

  /**
   * Checks if the source input exist.
   * 
   * @param source String literal of the user inputed source.
   * @param client The WattDepotClient
   * @return true if the source exist, false if it does not exist.
   */
  public boolean sourceChecker(String source, WattDepotClient client) {
    try {
      client.getSource(source);
      return true;
    }
    catch (WattDepotClientException e) {
      System.out.println("ERROR: Source " + source + " does not exist.");
      return false;
    }
  }
}
